package se.slp.test1;

import java.util.List;

import android.app.Activity;
import android.content.Intent;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;


public class Report extends Activity{
		private DataHelper dh;
		private String strReceipInput1;
		Intent launch_firstPage;

	/** Called when the activity is first created. */
		

	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	    	super.onCreate(savedInstanceState);
	        setContentView(R.layout.report);	
	        this.dh = new DataHelper(this);
	        TextView set_name  = (TextView)findViewById(R.id.set_name);
	        TextView set_weight  = (TextView)findViewById(R.id.set_weight);
	        TextView set_height  = (TextView)findViewById(R.id.set_height);
	        TextView set_sex  = (TextView)findViewById(R.id.set_sex);
	        TextView set_risk  = (TextView)findViewById(R.id.set_risk);
			TextView set_advice = (TextView)findViewById(R.id.set_advice);
			ImageButton btn_ok = (ImageButton)findViewById(R.id.report_ok);
			ImageButton btn_del = (ImageButton)findViewById(R.id.report_del);
			
			
			
			
			
			strReceipInput1 = getIntent().getStringExtra("strInput1");
			
			//Cursor c = dh.rawQuery("SELECT * FROM " + "account" , null);
	        List<String> data_Row = this.dh.selectRow(strReceipInput1);
	        StringBuilder sb = new StringBuilder();
	        //sb.append("Data in database:\n");
	        int i = 0;
	        for (String name : data_Row) {
	           //sb.append(name + " ");
	           i = i+1;
	           if( i==1)
	           {
	        	   set_name.setText(name.toString());
	           }
	           else if(i==2){
	        	   set_weight.setText(name.toString());
	           }
	           else if(i==3){
	        	   set_height.setText(name.toString());
	           }
	           else {
	        	   set_sex.setText(name.toString());
	           }
	           
	           if(i==4){
	        	    i=0;
	           }
	           
	        }
	        //Log.d("EXAMPLE", "names size - " + data_Row.size());
	         	        
	      //set_advice.setText(sb.toString());
	        
	       btn_ok.setOnClickListener(new OnClickListener() {
				
				public void onClick(View v) {
					
				launch_firstPage = new Intent(getApplicationContext(),SLPTestActivity.class);  
				startActivity(launch_firstPage);
				
			}
		});

	        
	       btn_del.setOnClickListener(new OnClickListener() {
				
				public void onClick(View v) {
				//////////// DELETE ROW FROM DATABASE
				dh.deleteRow(strReceipInput1);
				launch_firstPage = new Intent(getApplicationContext(),SLPTestActivity.class);  
				startActivity(launch_firstPage);
				
			}
		});
	        
	    }//end on Create
	    
	    
	    
    
}
